package com.lv.jie.controller;

import com.lv.jie.service.VideoService;
import com.lv.jie.utils.JsonResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * @author 24694
 */
@RestController
@RequestMapping("/video")
public class VideoController {

    @Resource
    VideoService videoService;

    @ApiOperation("数据库中所有视频")
    @GetMapping("/listVideo")
    public JsonResult listVideo(String token){
        return videoService.listVideo(token);
    }

    @ApiOperation("根据视频id查询视频")
    @GetMapping("/selectByPrimaryKey")
    public JsonResult selectByPrimaryKey(Integer id, String token){
        return videoService.selectByPrimaryKey(id, token);
    }

    @ApiOperation("上传视频")
    @PostMapping("/insertSelective")
    public JsonResult insertSelective(Integer userId, Integer typeId, MultipartFile video, String token){
        return videoService.insertSelective(userId, typeId, video, token);
    }

    @ApiOperation("删除视频")
    @DeleteMapping("/deleteByPrimaryKey")
    public JsonResult deleteByPrimaryKey(Integer id, String token){
        return videoService.deleteByPrimaryKey(id,token);
    }
}
